<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">

<h:head></h:head>
<h:body>

	<ui:include src="WelcomePage.xhtml" />

	<h:form id="formConsultVehicle">
		<p:growl showDetail="true"></p:growl>
		<p:panel header="Consulta de Veículo">
			<p:messages id="globalMessages"></p:messages>
			<h:panelGrid columns="3">
				<h:outputLabel id="labelPlaque" value="Placa:" for="textBoxPlaque"></h:outputLabel>
				<p:inputText id="textBoxPlaque"
					value="#{vehicleBean.vehicle.plaque}"></p:inputText>
				<br />

				<h:outputLabel id="labelChassis" value="Chassis:"
					for="textBoxChassis"></h:outputLabel>
				<p:inputText id="textBoxChassis"
					value="#{vehicleBean.vehicle.chassis}"></p:inputText>
				<p:message for="textBoxChassis" id="errorMessageChassis"></p:message>

				<h:outputLabel id="labelModel" value="Modelo:" for="textBoxModel"></h:outputLabel>
				<p:inputText id="textBoxModel" value="#{vehicleBean.vehicle.model}"></p:inputText>
				<br />
			</h:panelGrid>
			<h:panelGrid columns="2">
				<p:commandButton id="buttonSearchVehicle" value="Pesquisar"
					action="#{vehicleBean.search}" update="@form"></p:commandButton>

				<p:commandButton id="buttonClear" value="Limpar" action="#"></p:commandButton>
			</h:panelGrid>
			<h:panelGrid columns="5" id="panelGridVehicles" width="100%">

				<p:dataTable var="vehicle" id="dataTableVehicles"
					value="#{vehicleBean.vehicles}" rowKey="#{vehicle.id}"
					selectionMode="single" selection="#{vehicleBean.vehicleSelected}"
					paginator="true" rows="5" sortBy="#{vehicle.id}">
					<p:column rendered="false">
						<f:facet name="header">
							<h:outputText value="id"></h:outputText>
						</f:facet>
						<h:outputText value="#{vehicle.id}"></h:outputText>
					</p:column>

					<p:column>
						<f:facet name="header">
							<h:outputText value="Placa"></h:outputText>
						</f:facet>
						<h:outputText value="#{vehicle.plaque}"></h:outputText>
					</p:column>
					<p:column>
						<f:facet name="header">
							<h:outputText value="Chassis"></h:outputText>
						</f:facet>
						<h:outputText value="#{vehicle.chassis}"></h:outputText>
					</p:column>
					<p:column>
						<f:facet name="header">
							<h:outputText value="Modelo"></h:outputText>
						</f:facet>
						<h:outputText value="#{vehicle.model}"></h:outputText>
					</p:column>
					<p:column>
						<f:facet name="header">
							<h:outputText value="Grupo"></h:outputText>
						</f:facet>
						<h:outputText value="#{vehicle.groupVehicle}"></h:outputText>
					</p:column>
					<p:column>
						<f:facet name="header">
							<h:outputText value="R$ por KM"></h:outputText>
						</f:facet>
						<h:outputText value="#{vehicle.rateKmTraveled}"></h:outputText>
					</p:column>
					<p:column>
						<f:facet name="header">
							<h:outputText value="R$ KM Livre"></h:outputText>
						</f:facet>
						<h:outputText value="#{vehicle.rateKmFree}"></h:outputText>
					</p:column>


				</p:dataTable>
			</h:panelGrid>
			<h:panelGrid columns="4">
				<p:commandButton id="buttonInclude" value="Incluir"
					action="#{vehicleBean.includeVehicle}">
				</p:commandButton>
				<p:commandButton id="buttonUpdate" value="Alterar"
					action="#{vehicleBean.update}">
				</p:commandButton>
				<p:commandButton id="buttonDetails" value="Detalhar"
					update=":formConsultVehicle:detailsVehicle"
					oncomplete="vehicle.show()" title="Detalhar">
				</p:commandButton>
				<p:commandButton id="buttonDelete" value="Deletar" title="Deletar"
					action="#{vehicleBean.delete}" update="panelGridVehicles">
				</p:commandButton>
			</h:panelGrid>
		</p:panel>

		<p:dialog header="Detalhes do Veículo" widgetVar="vehicle"
			resizable="false" id="vehicleDialog" showEffect="fade"
			hideEffect="fade" modal="true">
			<h:panelGrid id="detailsVehicle" columns="2">
				<h:outputText value="Id:"></h:outputText>
				<h:outputText value="#{vehicleBean.vehicleSelected.id}"></h:outputText>
				<h:outputText value="Placa:"></h:outputText>
				<h:outputText value="#{vehicleBean.vehicleSelected.plaque}"></h:outputText>
				<h:outputText value="Chassis:"></h:outputText>
				<h:outputText value="#{vehicleBean.vehicleSelected.chassis}"></h:outputText>
				<h:outputText value="Modelo:"></h:outputText>
				<h:outputText value="#{vehicleBean.vehicleSelected.model}"></h:outputText>
				<h:outputText value="Grupo:"></h:outputText>
				<h:outputText value="#{vehicleBean.vehicleSelected.groupVehicle}"></h:outputText>
				<h:outputText value="R$ por KM:"></h:outputText>
				<h:outputText value="#{vehicleBean.vehicleSelected.rateKmTraveled}"></h:outputText>
				<h:outputText value="R$ KM Livre:"></h:outputText>
				<h:outputText value="#{vehicleBean.vehicleSelected.rateKmFree}"></h:outputText>
			</h:panelGrid>
		</p:dialog>


	</h:form>
</h:body>

</html>